#include<iostream>
using namespace std;

int main() {
	int n, a[20][20]={0}, step=1, direc=3, x=0, y=0;
	bool v[20][20] = {false};
	int dx[4] = {0, 1, 1,-1};
	int dy[4] = {1,-1, 0, 1};

	cin >> n;
	while(true) {
		a[x][y] = step++;
		v[x][y] = true;

		if (step > n*n)
			break;

		if (direc == 0 || direc == 2) {
			++direc %= 4;
		}

		while (x + dx[direc] < 0 || x + dx[direc] >= n ||
			   y + dy[direc] < 0 || y + dy[direc] >= n || 
			   v[x + dx[direc]][y + dy[direc]]) {
			++direc %= 4;
		}
		x = x + dx[direc];
		y = y + dy[direc];
	}

	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			printf("%4d", a[i][j]);
		}
		cout << endl;
	}
	return 0;
}
